<template>
  <div class="app-container">
    <div class="title">
      <h1>{{ title }}</h1>
    </div>

    <ul>
      <li v-for="(item, index) in detailList" :key="index">
        <template v-if="item.type === '1'">
          <p v-for="(subIten, index) in item.content" :key="index">
            {{ subIten }}
          </p>
        </template>
        <template v-else>
          <el-image
            style="width: 500px"
            :src="item.url"
            :preview-src-list="[item.url]"
          >
          </el-image>
        </template>
      </li>
    </ul>
  </div>
</template>

<script>
import { getLawInfoApi } from "@/wss/api/doc/law.js";
//
export default {
  data() {
    return {
      detailList: [],
      title: "",
    };
  },
  mounted() {
    if (this.$route.query.esId) {
      this.getLawInfoApiMet({ id: this.$route.query.esId });
      console.log(1);
    } else {
      this.getLawInfoApiMet({ id: this.$route.query.id });
      console.log(2);
    }
  },
  methods: {
    async getLawInfoApiMet(id) {
      let result = await getLawInfoApi(id).then((res) => res);
      console.log(result);
      if (result.code == 200 && result.data) {
        this.title = result.data.name;
        this.detailList = result.data.info;
      } else {
        this.title = "目前还没有数据";
      }
    },
  },
};
</script>
<style lang="scss" scoped>
.app-container {
  .title {
    text-align: center;
    font-family: "MicrosoftYaHei", "Microsoft YaHei";
    font-weight: 400;
    font-style: normal;
    font-size: 20px;
    color: #e37709;
  }
  ul {
    padding: 0px;
    li:last-child {
      height: 40px;
    }
    li {
      list-style: none;
      margin: 32px 0px;
      font-size: 16px;
      font-family: "PingFangSC-Regular", "PingFang SC";
      span {
        font-family: "PingFangSC-Regular", "PingFang SC";
      }
      img {
        height: 200px;
        width: 200px;
      }
    }
  }
}
.details {
  .breadcrumbBox {
    height: 50px;
    line-height: 50px;
  }
  padding: 20px;

  .opinion {
    color: #f2bc58;
    margin-bottom: 20px;
  }

  .AllcontentBox {
    padding-bottom: 50px;
  }
  .laws-update {
    background-color: #f5f5f5;
    padding-bottom: 10px;

    .top {
      display: flex;
      align-items: center;
      h1 {
        margin-right: 30px;
      }
    }
    .content {
      font-size: 13px;
      color: #999999;
    }
  }
}
</style>